package com.classicmodels.model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;




public class DataSource {

    private static Connection connection;

    public static Connection getConnection() throws SQLException, ClassNotFoundException{
        if(connection==null){
          connection = conectarBaseDeDatos();
        }
        return connection;
    }

    private static final String CONNECTION_STRING = "jdbc:mysql://192.168.0.110/classic_models_inc";
    private static final String USUARIO = "curso";
    private static final String PASSWORD  = "curso";


     private static Connection conectarBaseDeDatos() throws  SQLException, ClassNotFoundException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection c = DriverManager.getConnection(CONNECTION_STRING, USUARIO, PASSWORD);
        return c;

    }

}

